home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: Sockets don't work under VC++ 4.0 ?!!
- Date: 14 Jan 1996 11:12:59 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4daofr$41b@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe8.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 14, 1996 00:54:49 in article <Sockets don't work under VC++ 4.0
- ?!!>, 'Gavin Williams <gavin@metronet.com>' wrote:
-
-
- >I finally got around to doing a little Windows Sockets programming in VC++
-
- >4.0 today and was quickly greeted with an ugly problem--I can't get it to
-
- >create a socket.
- >
- >The CSocket::Create() function consistently failed, and
- >CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the
- CHATTER
- >sample program, and its socket creation failed with the same error.
- >
- >Then I tried tried straight socket API calls (as opposed to using the
- CSocket
- >or CAsyncSocket classes). The "socket" function also failed with the
- >WSAEPROTOTYPE error.
- >
- >Finally, I tried some simple sockets code in VC++ 1.52c and VC++ 2.2. The
-
- >code *worked* in both cases. The *exact same code* works fine when
- compiled
- >with 2.2 but fails when compiled with 4.0.
- >
-
- I haven't used the MFC classes, but raw winsock API works just fine for
- me. I started with 2.2 and now using 4.0 with equal success.
-
- >Here's a sample of my test code:
- >
- >WSADATA wsadata;
- >WSAStartup( 0x0101, &wsadata );
-
- You really should capture and test the return code from WSAStartup --
- although it's never failed for me so it may be a moot point.
-
- >
- >SOCKET sock;
- >if( INVALID_SOCKET == (sock = socket( PF_INET, SOCK_STREAM, 0 )) )
-
- Hmm, I use AF_INET -- didn't immediately find the docs on this but
- PF_INET is specified in the 16-bit winsock 1.1 specs. Try AF_INET.
-
- > {
- > int i = WSAGetLastError();
- > }
- >
- >WSACleanup();
- >
- >Two other tidbits: I'm running NT 3.51, and Microsoft's knowledge base
- >contained nothing about this problem.
- >
- Right. I know I have the documentation on winsock 2.0 on one of my
- MSDN CD's but can't find it right now. Oct 95 CD still has version
- 1.1 reference with some paragraphs under the win32 sdk which don't
- help much.
-
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-